//package com.hongwu.landscapevideocameracustom;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.v7.app.AppCompatActivity;
//import android.util.Log;
//import android.view.View;
//import android.widget.Button;
//import android.widget.Toast;
//
//import com.jmolsmobile.landscapevideocapture.VideoCaptureActivity;
//import com.jmolsmobile.landscapevideocapture.configuration.CaptureConfiguration;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.text.DecimalFormat;
//
//import static com.jmolsmobile.landscapevideocapture.configuration.PredefinedCaptureConfigurations.CaptureQuality.HIGH;
//import static com.jmolsmobile.landscapevideocapture.configuration.PredefinedCaptureConfigurations.CaptureResolution.RES_1440P;
//
///**
// *  @date 2017/5/8
// *  @authro lipeng
// */
//public class MainActivity extends AppCompatActivity {
//
//    private Button test;
//    CaptureConfiguration configuration;
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);
//
//
//        test = (Button) findViewById(R.id.test);
//        configuration = new CaptureConfiguration(RES_1440P, HIGH,60,1024,true,true);
//
//        test.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                final Intent intent = new Intent(MainActivity.this, VideoCaptureActivity.class);
//                intent.putExtra(VideoCaptureActivity.EXTRA_CAPTURE_CONFIGURATION,configuration);
//                intent.putExtra(VideoCaptureActivity.EXTRA_OUTPUT_FILENAME, "DFA2R34FAS12");
//                startActivityForResult(intent, 100);
//            }
//        });
//    }
//
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if(resultCode==RESULT_OK){
//            Log.e("hlog","视频路径："+data.getStringExtra("com.lipeng.extraoutputfilename"));
//            Log.e("hlog","视频大小："+getVideoSize(data.getStringExtra("com.lipeng.extraoutputfilename")+"M"));
//            double size=getVideoSize(data.getStringExtra("com.lipeng.extraoutputfilename"));
//            Toast.makeText(MainActivity.this,
//                    "视频大小："+size+"M",
//                            Toast.LENGTH_SHORT).show();
//        }else if(resultCode==9999){
//            final Intent intent = new Intent(MainActivity.this, VideoCaptureActivity.class);
//            intent.putExtra(VideoCaptureActivity.EXTRA_CAPTURE_CONFIGURATION,configuration);
//            intent.putExtra(VideoCaptureActivity.EXTRA_OUTPUT_FILENAME, "DFA2R34FAS12");
//            startActivityForResult(intent, 100);
//        }
//    }
//
//    private double getVideoSize(String videoPath){
//        File file = new File(videoPath);
//        long fileLength = 0;
//        try {
//            fileLength = getFileSize(file);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        DecimalFormat df = new DecimalFormat("#.00");
//        double fileSize = Double.valueOf(df.format((double)fileLength/1048576));
//
//        return fileSize;
//    }
//
//    /**
//     * 获取指定文件大小
//     *
//     * @return
//     * @throws Exception
//     */
//    private static long getFileSize(File file) throws Exception {
//        long size = 0;
//        if (file.exists()) {
//            FileInputStream fis = null;
//            fis = new FileInputStream(file);
//            size = fis.available();
//        } else {
//            file.createNewFile();
//            Log.e("获取文件大小", "文件不存在!");
//        }
//        return size;
//    }
//}
